package com.shujia.spark.mllib

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import java.io.StringReader
import scala.collection.mutable.ListBuffer

object Demo06IK {
  def fit(str: String): String = {
    val strReader: StringReader = new StringReader(str)
    val segmenter: IKSegmenter = new IKSegmenter(strReader, true)
    var lexeme: Lexeme = segmenter.next()
    val lb: ListBuffer[String] = ListBuffer[String]()
    while (lexeme != null) {
      val word: String = lexeme.getLexemeText
      lb.append(word)
      lexeme = segmenter.next()
    }
    lb.mkString(" ")
  }

  def main(args: Array[String]): Unit = {
    val str: String = "领导力与执行力区别"
    val str2:String = "兰智数加的学院"
    val str3:String = "武汉市长江大桥"

    println(Demo06IK.fit(str))
    println(Demo06IK.fit(str2))
    println(Demo06IK.fit(str3))


  }

}
